package com.zbkj.dal.base.enums;

import com.zbkj.dal.base.enums.show.EnumInterface;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
@AllArgsConstructor
public enum FundDirectionEnums implements EnumInterface<Integer> {
    ALL(0, "", "全部"),
    INCOME(1, "+", "收入"),
    OUTCOME(2, "-", "支出"),
    ;

    private final int code;
    private final String signal;
    private final String desc;


    @Override
    public Integer code() {
        return getCode();
    }

    @Override
    public String desc() {
        return getDesc();
    }

    public static String getSignalByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return Arrays.stream(FundDirectionEnums.values()).filter(e -> Objects.equals(e.getCode(), code)).map(FundDirectionEnums::getSignal).findFirst().orElse(null);
    }

    public static String splice(Integer direction, String amount) {
        return getSignalByCode(direction) + amount;
    }

}
